# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         hw04
# Description:
# Author:       98745
# Date:         2019/2/26
#-------------------------------------------------------------------------------

n=int(input('请输入一个整数：'))
i=1
list=[]
list0=range(1,n*n)
while i<=n :
    list1=list0[n*(i-1):n*i]
    list2 = []
    for x in list1:
           list2.append(x)
    list.append(list2)
    i+=1
#list[n-1].append(n*n)
list[n-1]=list[n-1]+[n*n]
for l in list:
    print(l)
list4=[]
j=1
while j<=n :
    list1=list0[j-1::3]
    list2 = []
    for x in list1:
           list2.append(x)
    list4.append(list2)
    j+=1
#list[n-1].append(n*n)
list4[n-1]=list4[n-1]+[n*n]
for l in list4:
    print(l)

